home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 30
/
Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso
/
Aminet
/
dev
/
lang
/
SmallEiffel.lha
/
SmallEiffel
/
man
/
cecil.txt
< prev
next >
Wrap
Text File
|
1998-12-22
|
3KB
|
76 lines
Cecil
Here is the information you need if you want to call some Eiffel
features from C code. To call C functions/macros from Eiffel see the
documentation about [1]externals (man/external in the distribution).
In order to call some Eiffel feature from C, you must use the -cecil
<cecil_file> option with command compile or compile_to_c. The
<cecil_file> allows you to give the list of features you want to call
from C. The corresponding stub routines will be automatically
generated by SmallEiffel.
When the -cecil option is used, command compile_to_c also produces an
additional C heading file which includes the needed C prototypes.
Your <cecil_file> must contain at least two lines. The first line is
the name of the C heading file to produce (it may be useful if you
need to create a C library). Other lines have the following structure:
<c_name> <living_eiffel_type> <feature_name>
The <c_name> is the name of the C function defined by compile_to_c to
wrap the Eiffel call. The couple <living_eiffel_type> <feature_name>
gives the complete name of the Eiffel feature to call. For example:
IsEiffelStringEmpty STRING empty
STRINGitem STRING item
strgrtr STRING infix ">"
array_of_int_count ARRAY[INTEGER] count
X_f X f
Keep in mind that the <living_eiffel_type> must be really alive: if
<living_eiffel_type> is ARRAY[INTEGER] for example, your Eiffel
program is supposed to create at least one ARRAY[INTEGER].
The name of the feature to call, <feature_name> may even be an infix
or a prefix feature name. The syntax is the same as the one used in
Eiffel source.
Since attributes are features, if is of course possible to access them
with this mechanism.
A call to X_f in the C code is equivalent to a call to x.f in Eiffel,
with x of type X or any descendant of X. Indeed,X_f takes care of late
binding. This means that X_f can be called on any (Current) argument
of type X or heir of X.
As <cecil_file> is parsed by the SmallEiffel parser, it may contain
Eiffel comments.
Here is one example of a Cecil file (others can be found in
directories SmallEiffel/lib_show/cecil/example*):
-- The name of the include C file :
eiffel.h
-- The features you want to call from C :
array_of_animal_item ARRAY[ANIMAL] item
array_of_animal_lower ARRAY[ANIMAL] lower
array_of_animal_upper ARRAY[ANIMAL] upper
cry ANIMAL cry
string_to_external STRING to_external
People who tinker with the C code generated by SmallEiffel, not
limiting themselves to the Cecil and/or external interfaces, should
also read [2]this page about the C code generated by SmallEiffel.
Otherwise they might get into trouble.
[Line]
Copyright © Dominique COLNET and Suzanne COLLIN - [3]<colnet@loria.fr>
Last update: Monday December 7th, 1998, by OZ.
References
1. file://localhost/home/colnet/SmallEiffel/man/man/external.html
2. file://localhost/home/colnet/SmallEiffel/man/man/c_code.html
3. mailto:colnet@loria.fr